package com.ddtc.repo;

import com.ddtc.object.WxAutoReply;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

/**
 * Created by dingd on 2018-07-29.
 */
public interface  WxAutoReplyRepository extends CrudRepository<WxAutoReply,Integer> {

//    @Query(nativeQuery = true,value = "select war.reply from wx_auto_reply war where war.key_like = :keyWord " +
//            "and  war.id BETWEEN :index AND  :index + 1000 limit 0,1")
//    String getContent(@Param("keyWord")String keyWord, @Param("index")Integer integer);


    WxAutoReply findByRoleAndSessionFrom(String role, String sessionFrom);

    @Query(nativeQuery = true,value = "select reply from wx_auto_reply  where wx_auto_reply.role = :role " +
           "and wx_auto_reply.key_like = :keyWord")
    String getContent(@Param("role")String role, @Param("keyWord")String keyWord);


    //WxAutoReply findByRoleAndKeyLike(String role, String keyLike);

}
